package Day11;

import java.util.Scanner;
// 1:无需package
// 2: 类名必须Main, 不可修改
/**
 * 2021Java真题:小平方
 * https://www.lanqiao.cn/problems/2378/learning/
 */
public class Main2 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        //在此输入您的代码...
        int n = scan.nextInt();
        int count = 0;
        for(int i = 1; i < n; i++){
          //不用除法是为了防止精度的丢失
          if((i * i) % n * 2 < n){
            count++;
          }
        }
        System.out.println(count);
        scan.close();
    }
}